//
//  ShareMedia.m
//  Bespoke
//
//  Created by Cheng on 12/8/13.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "ShareMedia.h"
#import "DetailViewController.h"

@implementation ShareMedia
@synthesize delegate;
@synthesize Array_ShareMedia,Tablecell;

- (void)OptionArray:(NSMutableArray *)ShareMedia
{
    Array_ShareMedia = ShareMedia;
}

#pragma mark - UITableViewDelegate

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    tableView.scrollEnabled = NO;
    NSString *ButtonCellIdentifier = @"ButtonCell";
    Tablecell = [tableView dequeueReusableCellWithIdentifier:ButtonCellIdentifier];
    
    UIView *bgColorView = [[UIView alloc] init];
    UIColor *UC_skyblue= [UIColor colorWithRed:206.0/255.0 green:235.0/255.0 blue:236.0/255.0 alpha:1.0];
    [bgColorView setBackgroundColor:UC_skyblue];
    
    if (Tablecell == nil) {
        
        Tablecell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ButtonCellIdentifier];
        //[Tablecell setBackgroundColor:nil];
        Tablecell.textLabel.text = [Array_ShareMedia objectAtIndex:indexPath.row];
        Tablecell.textLabel.textColor = [UIColor darkGrayColor];
        Tablecell.textLabel.font = [UIFont fontWithName:@"Times New Roman" size:15];
        //Tablecell.frame = CGRectMake(20, 0, 300.0, 20);
        //[Tablecell setSelectionStyle:UITableViewCellSelectionStyleGray];
        
        [Tablecell setSelectedBackgroundView:bgColorView];
        
        if([Tablecell.textLabel.text isEqualToString:@"Facebook"])
            [Tablecell.imageView setImage:[UIImage imageNamed:@"g_facebook.png"]];
        else if ([Tablecell.textLabel.text isEqualToString:@"Twitter"])
            [Tablecell.imageView setImage:[UIImage imageNamed:@"g_twitter.png"]];
        else if ([Tablecell.textLabel.text isEqualToString:@"Send email"])
            [Tablecell.imageView setImage:[UIImage imageNamed:@"g_email.png"]];
        else if ([Tablecell.textLabel.text isEqualToString:@"Add Group"])
            [Tablecell.imageView setImage:[UIImage imageNamed:@"Add_Symbol.png"]];
        else
            [Tablecell.imageView setImage:[UIImage imageNamed:@"button_off.png"]];

    }
    
    return Tablecell;
}
/***
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{	
	
	UIView* customView = [[UIView alloc] init];
     
	// create the button object
	UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
	headerLabel.backgroundColor = [UIColor clearColor];
	//headerLabel.opaque = NO;
	headerLabel.textColor = [UIColor darkGrayColor];
	//headerLabel.highlightedTextColor = [UIColor whiteColor];
	headerLabel.font = [UIFont fontWithName:@"Times New Roman" size:15];
    
	// If you want to align the header text as centered
    headerLabel.frame = CGRectMake(0, 0, 300.0, 20);
    if(section == 0)
        headerLabel.text = @"MY GROUPS";
    else
    headerLabel.text = @"SOCIAL MEDIA";
	 // i.e. array element
	[customView addSubview:headerLabel];
    
	return customView;
}**/

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    /**if ( Array_ShareMedia == nil )
        return 1;
    return [Array_ShareMedia count];**/
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    /**if (section == 0)
        return [[Array_ShareMedia objectAtIndex:0] count];
    else
        return [[Array_ShareMedia objectAtIndex:1] count];**/
    
    return self.Array_ShareMedia.count;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *NS_TableCell = [Array_ShareMedia objectAtIndex:indexPath.row];
    [delegate uiViewTouched_ShareMedia:NO ];
    [delegate DidSelected_Share:NS_TableCell];
}

#pragma mark - Touches

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    if( point.x > 0 && point.x < self.frame.size.width && point.y > 0 && point.y < self.frame.size.height )
    {
        [delegate uiViewTouched_ShareMedia:YES ];
        return YES;
    }
    
    [delegate uiViewTouched_ShareMedia:NO ];
    return NO;
}

@end
